package com.yjx.gulimall.product.agent;

import com.yjx.gulimall.common.to.SkuReductionTO;
import com.yjx.gulimall.common.to.SpuBoundTO;
import com.yjx.gulimall.common.utils.R;
import com.yjx.gulimall.common.vo.product.Bounds;
import com.yjx.gulimall.common.vo.product.Skus;
import com.yjx.gulimall.product.feign.CouponFeginService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhuyingcoder
 * @version 1.0
 * @date 2022-03-28 13:45
 */
@Component
public class CouponAgentService {

    @Autowired
    private CouponFeginService couponFeginService;

    /**
     * 保存 积分信息
     * @param spuId
     * @param bounds
     * @return
     */
    public R saveSpuBounds(Long spuId, Bounds bounds){

        SpuBoundTO spuBoundTO = new SpuBoundTO();
        spuBoundTO.setSpuId(spuId);
        spuBoundTO.setBuyBounds(bounds.getBuyBounds());
        spuBoundTO.setGrowBounds(bounds.getGrowBounds());

        return couponFeginService.saveBounds(spuBoundTO);
    }


    /**
     * 保存 满减信息
     * @param skuId
     * @param skus
     * @return
     */
    public R saveSkuReduction(Long skuId, Skus skus){

        SkuReductionTO skuReductionTO = new SkuReductionTO();
        BeanUtils.copyProperties(skus,skuReductionTO);
        skuReductionTO.setSkuId(skuId);

        return couponFeginService.saveSkuReduction(skuReductionTO);
    }

}
